package podman

import (
	"github.com/containers/podman/v5/pkg/bindings/containers"
	"github.com/containers/podman/v5/pkg/domain/entities"
	"github.com/containers/podman/v5/pkg/domain/entities/reports"
)

func (c *Client) CreateContainerWithSpec(sb *SpecBuilder) (entities.ContainerCreateResponse, error) {
	return containers.CreateWithSpec(c.conn, sb.Build(), nil)
}

func (c *Client) StartContainer(id string, ob *OptBuilder) error {
	if ob != nil {
		return containers.Start(c.conn, id, ob.BuildStartOptions())
	}
	return containers.Start(c.conn, id, nil)
}

func (c *Client) StopContainer(id string, ob *OptBuilder) error {
	if ob != nil {
		return containers.Stop(c.conn, id, ob.BuildStopOptions())
	}
	return containers.Stop(c.conn, id, nil)
}

func (c *Client) RemoveContainer(id string, ob *OptBuilder) ([]*reports.RmReport, error) {
	if ob != nil {
		return containers.Remove(c.conn, id, ob.BuildRemoveOptions())
	}
	return containers.Remove(c.conn, id, nil)
}

func (c *Client) ListContainers(ob *OptBuilder) ([]entities.ListContainer, error) {
	return containers.List(c.conn, ob.BuildListOptions())
}
